package m.html.form;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TableGroup implements ITableColumn{
    private final String title;
    private final TableColumn[] columns;
    @Override
    public String getTitle() {
        return title;
    }
    public static TableGroup ins(String title,TableColumn... columns){
        return new TableGroup(title,columns);
    }
    private TableGroup(String title,TableColumn[] columns) {
        this.title = title;
        this.columns=columns;
    }

    public TableColumn[] getColumns() {
        return columns;
    }

    @Override
    public FormEvent[] getLinks() {
        List<FormEvent> ls=new ArrayList<>();
        for(TableColumn c : columns){
            ls.addAll(Arrays.asList(c.getLinks()));
        }
        return ls.toArray(new FormEvent[0]);
    }
}
